{extend name="index/base" /}
{block name="main"}
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
    <legend>创建菜单</legend>
</fieldset>

<form class="layui-form" lay-filter="example" action="{:url('save')}" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">菜单名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" id="title" lay-verify="title" autocomplete="off" placeholder="菜单名称" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">所属分类</label>
        <div class="layui-input-block">
            <select name="upid" lay-filter="aihao" id="upid">
                <option value="">无顶级栏目</option>
                {:tree_to_select($menu)}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">URL</label>
        <div class="layui-input-block">
            <input type="text" name="name" id="name" lay-verify="name" autocomplete="off" placeholder="URL" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" name="rank" id="rank" lay-verify="rank" autocomplete="off" placeholder="排序，数字越大越靠前，默认（不填写为 0）" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">显示</label>
        <div class="layui-input-block">
	      <input type="radio" name="is_show" id="is_show" value="1" title="显示" checked=""><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>显示</div></div>
	      <input type="radio" name="is_show" id="is_show" value="0" title="不显示"><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon layui-anim-scaleSpring"></i><div>不显示</div></div>
	    </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn">递 交</button>
        </div>
    </div>
</form>
<script>
layui.use(['form'], function(){
    var form = layui.form;
});
</script>
<script type="text/javascript" src="/static/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
    layui.use(['layer'],function(){
        $ = layui.jquery;
        layer = layui.layer;

        // 用户名控件获取焦点
        $('#uname').focus();
        // 回车登录
        $('input').keydown(function(e){
            if(e.keyCode == 13){
                dologin();
            }
        });
    });

    // 重新生成验证码
    function reloadImg(){
        $('#captchaimg').attr('src','{:captcha_src()}?rand='+Math.random());
    }

    function test() {
        var title   = $('#title').val();
        if(title == ''){
            layer.alert('请输入栏目名称',{icon:2});
            return false;
        }
        var name    = $('#name').val();
        var upid    = $('#upid').val();
        var rank    = $('#rank').val();
        var is_show = $('#is_show').val();
        $.post("{:url('save')}",{'title':title,'name':name,'upid':upid,'rank':rank,'is_show':is_show},function(res){
            if(res.code==200){
                layer.msg(res.msg);
                setTimeout(function(){window.location.href = '/index.php/bm'},1000);
            }else{
                layer.alert(res.msg,{icon:2});
            }
        },'json');
    }

</script>

{/block}